<template>
	<view class="product-bg">
		<view class="explosion" :style="'margin-top: 22rpx;background:url(' + item.background +';'">
			<view class="hd skeleton-rect">
				<view class="title" style="color:rgba(0, 0, 0, 1);">{{item.name}}</view>
				<view class="txt">
					{{item.intro}}
				</view>
			</view>
			<view class="videoBox">
				<!-- #ifndef APP-PLUS -->
				<block v-if="videoline">
					<view class="item">
						<view v-show="!controls" style="width:100%;height:100% ">
							<video id="myVideo" :src='encodeURI(videoline)' object-fit="contain" controls style="width:100%;height:100%;" objectFit="cover"
								show-center-play-btn show-mute-btn="true" auto-pause-if-navigate :custom-cache="false"
								:enable-progress-gesture="false" :poster="imgUrls[0]" @pause="videoPause"></video>
						</view>
						<view class="poster ddPost" v-show="controls">
							<image class="image" :src="imgUrls[0]"></image>
						</view>
						<view class="stop" v-show="controls" @click.stop="bindPause">
							<image class="image" src="/static/images/stop.png"></image>
						</view>
					</view>
				</block>
				<!-- #endif -->
				<block v-if="!videoline">
					<view class="item" style="position: relative;">
						<view class="poster ddPost">
							<image class="image" :src="item.path"></image>
						</view>
					</view>
				</block>
			</view>
			<view class="bd" v-if="item.products">
				<view class="item skeleton-rect" @click="goDetail(citem)" v-for="(citem,index) in item.products.list"
					:key="index">
					<view class="cover">
						<image :src="citem.image" mode="aspectFill"></image>
					</view>
					
					<view class="name" style="font-weight: bold;margin-top: 15rpx;width: 100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;">
						{{citem.store_name}}
					</view>
				</view>
				<navigator :url="'/pages/columnGoods/HotNewGoods2/index?type=' + item.index + '&name=' + item.name" class="all" style="display: flex;justify-content: center;align-items: center;" hover-class="none">
					<image src="/static/svg/quanbu.svg" style="width: 30rpx;height: 30rpx;margin-right: 10rpx;"></image>
					<view class="label" style="color: #ff2f00;">
						查看全部商品
					</view>
				</navigator>
			</view>
		</view>
		<!-- #ifdef APP-PLUS -->
		<view v-if="!isPlay" style="width: 750rpx; height: 750rpx;">
			<video id="myVideo" class="goods-video" :src='videoline' controls show-center-play-btn show-mute-btn="true"
				autoplay="true" auto-pause-if-navigate :custom-cache="false" :enable-progress-gesture="false"
				:poster="imgUrls[0]" @pause="videoPause"></video>
		</view>
		<!-- #endif -->
	</view>
</template>

<script>
	
	export default {
		name: 'indexMoudle',
		props: {
			item: {
				type: Object,
				default: () => {}
			},
		},
		data() {
			return {
				// titleConfig: this.dataConfig.titleConfig.value,
				// desConfig: this.dataConfig.desConfig.value,
				// explosiveMoney: this.dataConfig.menuConfig.list,
				// themeColor: this.dataConfig.themeColor.color[0].item,
				// bgColor: this.dataConfig.bgColor.color,
				// mbConfig: this.dataConfig.mbConfig.val,
				// boxColor: this.dataConfig.boxColor.color[0].item
				mdList: [],
				imgUrls: [],
				videoline: '',
				controls: true,
				isPlay: true,
				videoContext: '',
				autoplay: true
			};
		},
		mounted() {
			if(this.item.video_open == 1 && this.item.video_link != ''){
				this.videoline = this.item.video_link
			}
			
			if (this.videoline) {
				this.imgUrls = [this.item.path]
			}
			// #ifndef APP-PLUS
			this.videoContext = uni.createVideoContext('myVideo', this);
			// #endif
		},
		// mounted() {
		//   if(this.item.video_open == 1 && this.item.video_link != ''){
		//     this.videoline = this.item.video_link
		//   }
		  
		//   if (this.videoline) {
		//   	this.imgUrls.shift()
		//   }
		//   // #ifndef APP-PLUS
		//   this.videoContext = uni.createVideoContext('myVideo', this);
		//   // #endif
		// },
		methods: {
			videoPause(e) {
				console.log('视频暂停')
				// #ifdef APP-PLUS
				this.isPlay = true
				this.autoplay = true
				// #endif
			},
			videoIsPause() {
				this.videoContext = uni.createVideoContext('myVideo', this);
				this.videoContext.pause();
			},
			bindPause: function() {
				// #ifndef APP-PLUS
				this.$set(this, 'controls', false)
				this.videoContext.play();
				this.autoplay = false
				// #endif
				// #ifdef APP-PLUS
				this.isPlay = false
				this.videoContext = uni.createVideoContext('myVideo', this);
				this.videoContext.play();
				// #endif
			},
			change: function(e) {
				this.current = e.detail.current;
				this.$set(this, 'currents', e.detail.current + 1);
			},
			// 查看图片详情
			openImage(index) {
				this.$emit('showSwiperImg', index)
			},
			goDetail(item) {
				let urls = item.info[2].value
				this.$util.JumpPath(urls);
			},
		}
	}
</script>

<style lang="scss">
	.explosion {
		width: 710rpx;
		margin-top: 20rpx;
		margin: 20rpx auto 0 auto;
		padding: 30rpx 20rpx;
		padding: 40rpx 30rpx 20rpx 30rpx;
		// background-color: #FFE5E3;
		background-size: 100% 100%;
		border-radius: 16px 16px 0px 0px;
		box-sizing: border-box;
		position: relative;
		overflow: hidden;
		// opacity: 0.16;
		
		&::before{
			content: '';
			position: absolute;
			width: 100%;
			height: 100%;
			background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22%20version%3D%221.1%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%221%22%20x1%3D%220%22%20x2%3D%221%22%20y1%3D%220%22%20y2%3D%220%22%20gradientTransform%3D%22matrix(-0.0030000000000001657%2C%200.973%2C%20-1.42264777696793%2C%20-0.0030000000000001657%2C%200.503%2C%200.024)%22%3E%3Cstop%20stop-color%3D%22%23f79a9a%22%20stop-opacity%3D%221%22%20offset%3D%220%22%3E%3C%2Fstop%3E%3Cstop%20stop-color%3D%22%23fffdc9%22%20stop-opacity%3D%221%22%20offset%3D%220.39%22%3E%3C%2Fstop%3E%3C%2FlinearGradient%3E%3C%2Fdefs%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22url(%231)%22%3E%3C%2Frect%3E%3C%2Fsvg%3E");
			background-size: cover;
			z-index: 1;
			opacity: 0.16;
			left: 0;
			top: 0;
		}
		  
		.hd {
			// display: flex;
			// align-items: center;
			position: relative;
			z-index: 10;

			.title {
				font-size: 32rpx;
				font-weight: bold;
				margin-right: 12rpx;
			}

			image {
				width: 147rpx;
				height: 35rpx;
				margin-right: 20rpx;
			}

			.txt {
				// padding: 0 10rpx;
				// height: 36rpx;
				// line-height: 36rpx;
				// // background: linear-gradient(90deg, rgba(255, 168, 0, 1) 0%, rgba(255, 34, 15, 1) 100%);
				// border-radius: 26rpx 0px 26rpx 0px;
				// color: #fff;
				// text-align: center;
				// font-size: 22rpx;
				// // box-shadow: 3px 1px 1px 1px var(--view-minorColorT);
				color: rgba(65, 65, 65, 1);
				font-size: 12px;
				font-weight: 400;
				line-height: 17px;
				letter-spacing: 1.0px;
				margin-top: 10rpx;
			}
		}

		.bd {
			display: flex;
			flex-wrap: wrap;
			margin-top: 28rpx;
			position: relative;
			z-index: 10;
			justify-content: space-between;

			.item {
				// display: flex;
				// align-items: center;
				// justify-content: space-between;
				position: relative;
				width: 314rpx;
				height: 272rpx;
				margin-bottom: 20rpx;
				margin-right: 20rpx;
				background-color: #fff;
				border-radius: 16rpx;
				padding: 20rpx;
				box-sizing: border-box;

				image {
					width: 140rpx;
					height: 140rpx;
				}
				
				.cover{
					height: 192rpx;
					image{
						width: 100%;
						height: 100%;
					}
				}

				.con-box {
					display: flex;
					flex-direction: column;
					justify-content: center;
					width: 130rpx;
					height: 100%;

					.title {
						color: #282828;
						font-size: 28rpx;
					}

					.con {
						color: #999999;
						font-size: 20rpx;
						margin-top: 2rpx;
					}

					.go {
						display: flex;
						align-items: center;
						justify-content: center;
						margin-top: 10rpx;
						width: 112rpx;
						height: 36rpx;
						border-radius: 18rpx;
						color: #fff;
						font-size: 26rpx;
						font-weight: bold;
						font-style: italic;

						image {
							width: 26rpx;
							height: 26rpx;
						}
					}
				}

				&:first-child .go {
					background: linear-gradient(90deg, rgba(75, 196, 255, 1) 0%, rgba(32, 126, 255, 1) 100%);
				}

				&:nth-child(2) .go {
					background: linear-gradient(90deg, rgba(255, 144, 67, 1) 0%, rgba(255, 83, 29, 1) 100%);
				}

				&:nth-child(3) .go {
					background: linear-gradient(90deg, rgba(150, 225, 135, 1) 0%, rgba(72, 206, 44, 1) 100%);
				}

				&:nth-child(4) .go {
					background: linear-gradient(90deg, rgba(255, 197, 96, 1) 0%, rgba(255, 156, 0, 1) 100%);
				}

				&:nth-child(2n) {
					margin-right: 0;
				}
			}
		}
		
		.all{
			width: 100%;
		}
	}
	
	.product-bg {
		width: 100%;
		height: fit-content;
		position: relative;
		margin-top: 40rpx;
		margin-bottom: 20rpx;
	}
	
	.product-bg swiper {
		width: 100%;
		height: 100%;
		position: relative;
	}
	
	.product-bg .slide-image {
		width: 100%;
		height: 100%;
		border-radius: 20rpx;
		overflow: hidden;
	}
	
	.product-bg .pages {
		position: absolute;
		// background-color: #fff;
		height: 34rpx;
		padding: 0 10rpx;
		border-radius: 3rpx;
		right: 30rpx;
		bottom: 30rpx;
		line-height: 34rpx;
		font-size: 24rpx;
		color: #050505;
	}
	
	#myVideo {
		width: 100%;
		height: 100%;
	}
	
	.goods-video {
		width: 100%;
		height: 100%;
	}
	
	.product-bg .item {
		position: relative;
		width: 100%;
		height: 100%;
		border-radius: 0;
		overflow: hidden;
	}
	
	.ddPost {
		position: absolute;
		top: 0;
		left: 0;
		height: 360rpx;
		width: 100%;
		z-index: 9;
		// margin-top: 20rpx;
	}
	
	.ddPost .image {
		width: 100%;
		height: 100%;
	}
	
	.product-bg .item .stop {
		position: absolute;
		top: 50%;
		left: 50%;
		width: 136rpx;
		height: 136rpx;
		margin-top: -68rpx;
		margin-left: -68rpx;
		z-index: 9;
	}
	
	.product-bg .item .stop .image {
		width: 100%;
		height: 100%;
	}
	
	.videoBox{
		margin-top: 20rpx;
		position: relative;
		z-index: 30;
		.item{
			width: 100%;
			height: 360rpx;
		}
	}
</style>
